package com.ruoyi.enlistIand.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.enlistIand.domain.IfmEnlistIand;
import com.ruoyi.enlistIand.service.IIfmEnlistIandService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 入伍（队）地Controller
 * 
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/enlistIand/EnlistIandIfm")
public class IfmEnlistIandController extends BaseController
{
    @Autowired
    private IIfmEnlistIandService ifmEnlistIandService;

    /**
     * 查询入伍（队）地列表
     */
    @PreAuthorize("@ss.hasPermi('enlistIand:EnlistIandIfm:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmEnlistIand ifmEnlistIand)
    {
        startPage();
        List<IfmEnlistIand> list = ifmEnlistIandService.selectIfmEnlistIandList(ifmEnlistIand);
        return getDataTable(list);
    }

    /**
     * 导出入伍（队）地列表
     */
    @PreAuthorize("@ss.hasPermi('enlistIand:EnlistIandIfm:export')")
    @Log(title = "入伍（队）地", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmEnlistIand ifmEnlistIand)
    {
        List<IfmEnlistIand> list = ifmEnlistIandService.selectIfmEnlistIandList(ifmEnlistIand);
        ExcelUtil<IfmEnlistIand> util = new ExcelUtil<IfmEnlistIand>(IfmEnlistIand.class);
        util.exportExcel(response, list, "入伍（队）地数据");
    }

    /**
     * 获取入伍（队）地详细信息
     */
    @PreAuthorize("@ss.hasPermi('enlistIand:EnlistIandIfm:query')")
    @GetMapping(value = "/{iandId}")
    public AjaxResult getInfo(@PathVariable("iandId") Long iandId)
    {
        return success(ifmEnlistIandService.selectIfmEnlistIandByIandId(iandId));
    }

    /**
     * 新增入伍（队）地
     */
    @PreAuthorize("@ss.hasPermi('enlistIand:EnlistIandIfm:add')")
    @Log(title = "入伍（队）地", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmEnlistIand ifmEnlistIand)
    {
        return toAjax(ifmEnlistIandService.insertIfmEnlistIand(ifmEnlistIand));
    }

    /**
     * 修改入伍（队）地
     */
    @PreAuthorize("@ss.hasPermi('enlistIand:EnlistIandIfm:edit')")
    @Log(title = "入伍（队）地", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmEnlistIand ifmEnlistIand)
    {
        return toAjax(ifmEnlistIandService.updateIfmEnlistIand(ifmEnlistIand));
    }

    /**
     * 删除入伍（队）地
     */
    @PreAuthorize("@ss.hasPermi('enlistIand:EnlistIandIfm:remove')")
    @Log(title = "入伍（队）地", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iandIds}")
    public AjaxResult remove(@PathVariable Long[] iandIds)
    {
        return toAjax(ifmEnlistIandService.deleteIfmEnlistIandByIandIds(iandIds));
    }
}
